package rpg.writer.scripts.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import rpg.client.model.ActorInfo;
import rpg.engine.client.GameObjectInfo;
import rpg.engine.model.DialogInfo;
import rpg.engine.model.GameEffect;
import rpg.engine.model.GameMap;
import rpg.engine.model.MagicArea;

public class ParsedScript {
	public static class Builder {
		private final String storyID;
		
		public Builder(String sID)  {
			super();
			storyID = sID;
		}
		
		public ParsedScript build()  {
			return new ParsedScript(this);
		}

		private final List<GameMap> maps = new ArrayList<GameMap>();
		public Builder gameMap(GameMap map) {
			maps.add(map);
			return this;
		}
		
		private final List<GameEffect> startEffects = new ArrayList<GameEffect>();
		public Builder effect(GameEffect e)  {
			startEffects.add(e);
			return this;
		}
		
		private final List<DialogInfo> dialogs = new ArrayList<DialogInfo>();
		public Builder dialog(DialogInfo e)  {
			dialogs.add(e);
			return this;
		}

		private final List<MagicArea> magicAreas = new ArrayList<MagicArea>();
		public Builder magicArea(MagicArea ma) {
			magicAreas.add(ma);
			return this;
		}

		private final List<ActorInfo> actors = new ArrayList<ActorInfo>();
		public Builder actor(ActorInfo actor) {
			actors.add(actor);
			return this;
		}

		private final List<GameObjectInfo> objects = new ArrayList<GameObjectInfo>();
		public Builder object(GameObjectInfo go) {
			objects.add(go);
			return this;
		}
	}
	
	private ParsedScript(Builder b)  {
		super();
		storyID = b.storyID;
		gameMaps.addAll(b.maps);
		startEffects = Collections.unmodifiableList(b.startEffects);
		dialogs.addAll(b.dialogs);
		actors.addAll(b.actors);
		magicAreas.addAll(b.magicAreas);
		objects.addAll(b.objects);
	}
	
	private final String storyID;
	public String getStoryID() {
		return storyID;
	}

	private final List<GameMap> gameMaps = new ArrayList<GameMap>();
	public List<GameMap> getGameMaps() {
		return gameMaps;
	}
	
	private final List<GameEffect> startEffects;
	public List<GameEffect> getStartEffects() {
		return startEffects;
	}

	private final List<DialogInfo> dialogs = new ArrayList<DialogInfo>();
	public List<DialogInfo> getDialogs() {
		return dialogs;
	}

	private final List<MagicArea> magicAreas = new ArrayList<MagicArea>();
	public List<MagicArea> getMagicAreas() {
		return magicAreas;
	}

	private final List<ActorInfo> actors = new ArrayList<ActorInfo>();
	public List<ActorInfo> getActors()  {
		return actors;
	}

	private final List<GameObjectInfo> objects = new ArrayList<GameObjectInfo>();
	public List<GameObjectInfo> getObjects() {
		return objects;
	}
}
